﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL.DateSet.PictureTableAdapters;
using DAL.DateSet;
using DAL;
namespace BLL.Wrapper
{
    public class PictureWrapper : PictureTableAdapter
    {
        public Picture.PictureDataTable getall()
        {
            return GetData();
        }

        public void addARecord(Picture.PictureRow row)
        {
            Insert(row.goodsID, row.pictureSrc, row.pictureType, row.picCreator, row.picCreatDate, row.picEditor, row.picEditDate);
        }

        public void deleteByID(int id)
        {
            string sql = "delete from ModifyRecord where pictureID = " + id.ToString();
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();
            helper.initOle();
            helper.delete(sql);
        }

        public void updateARecord(Picture.PictureRow row)
        {
            Picture.PictureDataTable table = GetData();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (Convert.ToInt32(table.Rows[i]["pictureID"]) == row.pictureID)
                {
                    table.Rows[i]["goodsID"] = row.goodsID;
                    table.Rows[i]["pictureSrc"] = row.pictureSrc;
                    table.Rows[i]["pictureType"] = row.pictureType;
                    table.Rows[i]["widthpicCreator"] = row.picCreator;

                    table.Rows[i]["picCreatDate"] = row.picCreatDate;
                    table.Rows[i]["picEditor"] = row.picEditor;
                    table.Rows[i]["picEditDate"] = row.picEditDate;
                    break;
                }
            }
            Update(table);
        }
    }
}
